<template>
  <nav-bar class="navBar">

    <div slot="left" class="back" @click="backClick">
      <img src="~assets/img/common/back.svg"/>
    </div>

    <div slot="center" class="title-box">
      <div @click="itemClick(index)" v-for="(item,index) in titles" class="title-item"
           :class="{active:index===currentIndex}">{{item}}
      </div>
    </div>
  </nav-bar>
</template>

<script>

  import NavBar from '../../../components/common/navbar/NavBar';

  export default {
    name: 'DetailNavBar',
    components: {NavBar},
    data() {
      return {
        titles: ['商品', '详情', '评论', '推荐'],
        currentIndex: 0
      };
    },
    methods: {
      itemClick(index) {
        this.currentIndex = index;

        this.$emit('titleClick',index)

      },

      backClick() {
        this.$router.back();
      }
    }
  };
</script>

<style scoped>

  .navBar {
    border-bottom: 1px solid #eeeeee;
  }

  .title-box {
    display: flex;
    justify-content: space-around;

  }

  .title-item {
    font-size: 14px;
    color: #999999;
  }

  .active {
    color: var(--color-high-text);
  }

  .back img {
    /*margin-top: 10px;*/
  }

</style>
